#min-max归一化，将开盘价，收盘价，最高价，最低价归一化
import sklearn


def normalize_data(df):
    min_max_scaler = sklearn.preprocessing.MinMaxScaler()#调用sklearn的最小最大值归一化函数MinMaxScaler()
    df['open'] = min_max_scaler.fit_transform(df.open.values.reshape(-1,1))#reshape(-1,1)表示将数据转换成1列
    df['high'] = min_max_scaler.fit_transform(df.high.values.reshape(-1,1))#然后再进行归一化
    df['low'] = min_max_scaler.fit_transform(df.low.values.reshape(-1,1))
    df['high'] = min_max_scaler.fit_transform(df['close'].values.reshape(-1,1))
    return df #将归一化的结果返回给df